<template>
	<view>
		<view class="header status_bar" :class="scrrol == true ? 'scrrolHeader' : ''">
			<view class="back iconfont icon-xiangzuo1" @tap="backPage"></view>
			<view class="text" :class="scrrol == true ? 'scrrolHeader' : ''">{{Lang.lang('我的發布')}}</view>
			<view class="back"></view>
			<!-- <view class="rule">规则</view> -->
		</view>


		<view class="nav">
			<block v-for="(item, index) in nav" :key="index">
				<view class="menu" :class="select == index ? 'menucolor' : ''" :data-index="index" @tap="setNavMenu">
					{{Lang.lang(item.menu)}}
				</view>
			</block>
		</view>
		<view class="clear_box"></view>
		<view class="clear_box02"></view>

		<view class="page_content">
			<view class="slide-main">
				<view class="list" v-for="(item,index) in log_list" :key="index">
					<liu-swipe-action :index="index" @clickItem="clickItem" :disable="item.state==1?false:true">
						<view class="publish_list">
							<view class="rank_box">
								<view class="rank">{{item.add_time}}</view>
								<view class="type" v-if="item.state ==1">{{Lang.lang('出售中')}}</view>
								<view class="type" v-else-if="item.state ==2">{{Lang.lang('已賣出')}}</view>
							</view>
							<!-- <view class="name_box">
								<view class="icon">
									<image src="../../../static/menu/menu18.png" mode="widthFix"></image>
								</view>
								<view class="name"></view>
								<view class="time">{{item.add_time}}</view>
							</view> -->
							<view class="sales_box">
								<view class="text">{{Lang.lang('出售數量')}}：</view>
								<view class="num">{{item.sell_num}} YYDM</view>
							</view>
							<view class="sales_box">
								<view class="text">{{Lang.lang('出售价格')}}：</view>
								<view class="num">{{item.sell_total_price}} USDT</view>
							</view>
							<view class="sales_box">
								<view class="text">{{Lang.lang('手续费')}}：</view>
								<view class="num">{{item.sell_fees}} YYDM</view>
							</view>
						</view>
					</liu-swipe-action>
				</view>
			</view>
		</view>


		<view class="confirm" :data-url="'/pages/personalcenter/publish/submit'" @click="gotopage">{{Lang.lang('發布掛單')}}</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				lang: 'en',
				link: '',
				pupu: false,
				scrrol: false,
				info: '',
				nav: [{
						menu: '全部',
					},
					{
						menu: '出售中',
					},
					{
						menu: '已賣出',
					}
				],
				select: 0,
				page: 0,
				log_list: []
			}
		},
		onLoad() {

		},
		onShow() {
			let that = this
			that.loadData()
		},
		methods: {
			loadData() {
				let that = this;
				that.page = 0;
				that.log_list = [];
				that.loadPageData();
			},
			loadPageData() {
				var that = this;
				that.page++;
				that.Net._get('api/wallet/myOtcYydmList', {
					page: that.page,
					type: that.select
				}, res => {
					if (res.code == 200) {
						//console.log(res)
						if (res.data.log_list == '') {

						} else {
							that.log_list = that.log_list.concat(res.data.log_list); //将数据拼接在一起
						}
					} else if (res.code == 0) {
						that.Msg.Success(res.msg, res => {});
					}
				});
			},
			setNavMenu(e) {
				let that = this;
				let index = e.currentTarget.dataset.index;
				that.select = index;
				that.loadData()

			},
			clickItem(e) {
				let that = this
				if (e.id == 2) {
					let row = that.log_list[e.index]
					that.otcYydmRevoke(row.id)
				}


			},
			otcYydmRevoke(id, index) {
				let that = this;
				that.Net._post('api/wallet/otcYydmRevoke', {
					id: id
				}, res => {
					if (res.code == 200) {
						that.Msg.Success(res.msg)
						setTimeout(function() {
							that.loadData()
						}, 500)

					}
				});
			},
			backPage() {
				uni.navigateBack({});
			},
			gotopage(e) {
				let url = e.currentTarget.dataset.url;
				uni.navigateTo({
					url: url
				});
			},
		},
		onPageScroll: function(Object) {
			//console.log(Object.scrollTop); //实时获取到滚动的值
			if (Object.scrollTop > 28) {
				this.scrrol = true;
				/* #ifdef APP-PLUS */
				/* #endif */
			} else if (Object.scrollTop < 28) {
				this.scrrol = false;
				/* #ifdef APP-PLUS */
				/* #endif */
			}
		},
		onReachBottom() {
			var that = this;
			that.loadPageData()
		},
	}
</script>

<style>
	.clear_box02 {
		height: 13vw;
	}

	.header {
		background-color: transparent !important;
	}

	.header .text {
		text-align: center;
	}

	.page_content {
		width: 92%;
		margin: 0 auto;
	}

	.scrrolHeader {
		width: 100%;
		background-color: #090909 !important;

	}

	.slide-main {
		width: 100%;

	}

	.list {
		width: 100%;
		margin-top: 4vw;
		overflow: hidden;
		border-radius: 4vw;
	}

	.publish_list {
		width: 100%;
		padding: 4vw;
		border-radius: 4vw;
		background-color: #1A1A1A;
	}

	.publish_list .rank_box {
		width: 100%;
		display: flex;
		align-items: center;
		border-bottom: 1px solid #4A4A4A;
		padding-bottom: 4vw;

	}

	.publish_list .rank_box .rank {
		flex: 1;
		font-size: 3.5vw;
		color: #BDBDBD;
	}

	.publish_list .rank_box .type {
		font-size: 3.5vw;
		color: #fff;
	}

	.publish_list .name_box {
		width: 100%;
		display: flex;
		align-items: center;
		margin-top: 4vw;
	}

	.publish_list .name_box .icon {
		width: 7vw;
		margin-right: 2vw;
	}

	.publish_list .name_box .icon image {
		width: 100%;
	}

	.publish_list .name_box .name {
		font-size: 4.5vw;
		color: #fff;
		flex: 1;
		font-weight: bold;
	}

	.publish_list .name_box .time {
		font-size: 3.5vw;
		color: #919191;
	}

	.publish_list .sales_box {
		width: 100%;
		display: flex;
		align-items: center;
		margin-top: 4vw;
	}

	.publish_list .sales_box .text {
		font-size: 3.5vw;
		color: #A3A3A3;
	}

	.publish_list .sales_box .num {
		font-size: 3.5vw;
		color: #fff;
	}

	.nav {
		width: 100%;
		padding: 0 10%;
		height: 13vw;
		display: flex;
		align-items: center;
		justify-content: space-between;
		position: fixed;
		left: 0;
		top: calc(17vw + var(--status-bar-height));
		z-index: 999999;
		background-color: #090909;
	}

	.nav .menu {
		height: 100%;
		line-height: 13vw;
		font-size: 4vw;
		color: #fff;
		font-weight: bold;
	}

	.menucolor {
		border-bottom: 5px solid #0055FE !important;
	}
</style>